//*****************************************************************************
// testingSuport.h
//
// Copyright 2009 by Magpie, http://www.magpieti.com
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//     http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************

#ifndef TESTING_SUPPORT_H
#define TESTING_SUPPORT_H

#define TRUE 1
#define FALSE 0

#define TEST(newName) testName = newName; printf("%s ********************************************\r\n", testName);
#define ITERATIVE_TEST(newName, currentIteration) testName = newName; iteration = currentIteration; printf("%s, iteration %d *******************************\r\n", testName, iteration);

#define fail() exit(-1);
#define assertEquals(x,y) if (x!=y) {printf("ERROR[%s].%d: Expected 0x%4x, got 0x%4x\r\n",testName, __LINE__, x, y); fail();}
#define assertNull(x) if (x!=NULL) {printf("ERROR[%s].%d: Value 0x%4x not null\r\n",testName, __LINE__, x); fail();}
#define assertNotNull(x) if (x==NULL) {printf("ERROR[%s].%d: Value is null\r\n",testName, __LINE__); fail();}
#define assertTrue(x) if (!x) {printf("ERROR[%s].%d: Not TRUE\r\n",testName, __LINE__); fail();}
#define assertFalse(x) if (x) {printf("ERROR[%s].%d: Not FALSE\r\n",testName, __LINE__); fail();}

#define TEST_NAME testName
#define TEST_ITERATION iteration

char* testName;
int8u iteration;

#endif // TESTING_SUPPORT_H
